<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="ja" xml:lang="ja" xmlns="http://www.w3.org/1999/xhtml" id="ngsdev-dot-org">
<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<meta http-equiv="content-script-type" content="text/javascript" />
	<meta http-equiv="content-style-type" content="text/css" />
	<script type="text/javascript" src="../src/AbstractSQL.js"></script>
	<link rel="stylesheet" type="text/css" href="./_assets/default.css" />
	<script type="text/javascript" src="./_assets/highlight.pack.js"></script>

	<title>AbstractSQL.js test</title>
	<script type="text/javascript">
		var form,code,db;
		hljs.tabReplace = '    ';
		hljs.initHighlightingOnLoad();
		function init() {
			form = document.getElementById("testform");
			code = form.code;
			onSubmit();
		}
		function outputText(text) {
			document.getElementById("output-div").innerHTML = "<div><pre class=\"language-sql\" id=\"output-pre\">"+(text||"").toString()+"</pre></div>";
			hljs.highlightBlock(document.getElementById("output-pre"),"  ");
		}
		function onSubmit() {
			//try{
				eval(code.value);
				outputText(sql);
			//} catch(e){
			//	outputText(e);
			//}
		}
	</script>
	
</head>
<body onload="init();">
<form onsubmit="onSubmit();return false;" id="testform">
<div>
<textarea name="code" style="width:44%;height:300px;float:left;">
var sql = new AbstractSQL("test");

sql.createTable([
	new AbstractSQL.Field("id",AbstractSQL.FieldType.INTEGER,10,true),
	new AbstractSQL.Field("name",AbstractSQL.FieldType.TEXT,255,false)
]);
sql.comment("insert");
sql.insert({ "id":101, "name":"長瀬敦史" });
sql.insert({ "id":100, "name":"長瀬敦史" },AbstractSQL.Conflict.REPLACE);
sql.comment("insert");
sql.count("id",[
	new AbstractSQL.Where("name","長%",AbstractSQL.Operator.LIKE)
]);

sql.update({ name:"あいうえ", id:12 },[
	new AbstractSQL.WhereList(AbstractSQL.Logic.OR,[
		new AbstractSQL.Where("id",100)
	])
],AbstractSQL.Conflict.REPLACE);

sql.select(["id","name"],[
	new AbstractSQL.WhereList(AbstractSQL.Logic.OR,[
		new AbstractSQL.Where("id",100),
		new AbstractSQL.Where("id","101")
	])
]);

sql.select("*",
	new AbstractSQL.Where("id",
		new AbstractSQL("test").select("id",null,10,new AbstractSQL.Order("id",true))
	)
);

</textarea>
<p style="padding-top:132px;width:5%;float:left;margin:0;text-align:center;"><input type="submit" value="eval &raquo;" /></p>
<div style="width:44%;height:300px;float:left;display:block;overflow:auto;" id="output-div"></div>
</div>
</form>
</body>
</html>
